<?php
		if(true){
		//page_1
			if ($_GET['page']) {
				$page = $_GET['page'];
				if(is_numeric($page)){
				}else{
					$page = 1;
				}
			} else {
				$page = 1;
			}
			$per_page = 10;//每页显示20条
			if($page<=1){$page=1;}//最大值还没有设置,在后面的db结果设置
			$start_from = ($page-1)*$per_page;
		}


	        require_once ("./includes/configure.php");
			require_once ("./includes/database.php");
			$db = Database :: Connect();
			$sql = "select * from xiaoqu "; //默认0为出租

			$wheresql = " where 1=1 ";
//			if($_GET['quyu']){
//				$sql .= " and quyu=".$_GET['quyu']." ";
//			}

//			if($_GET['quyu2']){
//				$where_sql .= " and quyu2=".$_GET['quyu2']." ";
//			}
		       if($_GET['zujin']){
				$zujincond = $_GET['zujin'];
				if(strpos($zujincond,"<")!==false)
				{
					$wheresql .= " and jiage".$zujincond;
				}else if(strpos($zujincond,">")!==false){
					$wheresql .= " and jiage".$zujincond;
				}
				else{
					$range = explode("-",$zujincond);
					$wheresql .= " and jiage>".$range[0]." and jiage<".$range[1];
				}
			}
			$sql .= $where_sql;

			 if($_GET['sort']){
				$sort = $_GET['sort'];
				$sql .= " order by ".$sort." limit $start_from,$per_page";
			}
			else{
             $sql.=" order by this_id desc limit $start_from,$per_page";
			}


			   if(true){
			//page_2
				$count_sql = "select count(*) from xiaoqu  $where_sql";

				$count_result = $db->GetResultSet($count_sql);
				while ($count_row = mysql_fetch_array($count_result)) {
					$total_item = $count_row[0];
				}
				$max_page = ceil($total_item/$per_page);
			}



			$rows = $db->GetResultSet($sql) or die ("数据库出错啦！");
?>
<div class="main_content">

	<div class="listleft">
	<div class="search-result2">
	<div class="quicktabs">
	<ul>
		<li class="slt"><span><a href="#/sale/"
			rel="nofollow">全部小区</a></span></li>
	<!--	<li class="map"><span class="map-ion"></span><span><a
			href="#">地图模式</a></span></li>-->
	</ul>
	</div>
	</div>

	<div style="margin: 10px 0px 5px 15px"></div>
	<div class="listing" style="margin-top: -11px;">
            <div class="nh_tab_bar">
                <div class="num">房客网找到<span><?php echo $total_item?></span>&nbsp;个符合要求的小区</div>

             <!--   <div class="pager"><div class="simple_multipage">

            <div class="pagelink noprexpage">&nbsp;</div>

                        <div class="current">1/969</div>

            <div class="pagelink nextpage"><a href="#" title="下一页">下一页</a></div>

</div></div>-->
                <div class="order_content">
                	<label>排序：</label>
                    <div id="selectorder_id">
                        <a href="#" class="select"><span class="select_item"><span class="txt">默认排序</span><span class="icon">&nbsp;</span></span>
                        <!--[if IE 7]><!--></a><!--<![endif]-->
                        <!--[if IE 8]><!--><!--<![endif]-->
                        <!--[if !IE]>--><!--<![endif]-->
                        <!--[if lte IE 6]>
                        <iframe src="" style="position:absolute;visibility:inherit; top:0px; left:-1px; width:99px; height:105px;z-index:-1;opacity:.0;filter:alpha(opacity=0); -moz-opacity:0;"></iframe>
                        <table><tr><td><![endif]-->
                        <ul>
                                             <li class="selected"><a href="<?php echo  deleteRepeatVar($current_url,'sort').'&sort=this_id desc' ?>"
			class="select_list" rel="nofollow">默认排序</a></li>
                      <li><a href="<?php echo deleteRepeatVar($current_url,'sort').'&sort=jiage desc' ?>" class="select_list"
			rel="nofollow">均价从高到低</a></li>
		<li><a href="<?php echo  deleteRepeatVar($current_url,'sort').'&sort=jiage asc' ?>" class="select_list"
			rel="nofollow">均价从低到高</a></li>
		<li><a href="<?php echo  deleteRepeatVar($current_url,'sort').'&sort=liulancishu desc' ?>" class="select_list"
			rel="nofollow">关注度从高到低</a></li>
		<li><a href="<?php echo  deleteRepeatVar($current_url,'sort').'&sort=liulancishu asc' ?>" class="select_list"
			rel="nofollow">关注度从低到高</a></li>
                                                </ul>
                        <!--[if lte IE 6]></td></tr></table></a><![endif]-->
                    </div>
                </div>
                <div style="clear:both;"></div>
            </div>
            <div style="clear:both;"></div>
                            	    <!-- table class="header" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td class="title">&nbsp;</td>
            <td>小区信息</td>
                        <td class="title1"><a href="http://beijing.anjuke.com/community/list/W0QQsZpQQstZ1" class="http://beijing.anjuke.com/community/list/W0QQsZpQQstZ2">均价/m<sup>2</sup></a></td>
            <td class="title1"><a href="http://beijing.anjuke.com/community/list/W0QQsZcQQstZ1" class="http://beijing.anjuke.com/community/list/W0QQsZcQQstZ2">涨跌幅</a></td>
                    </tr>
    </table -->
                    <ol id="list_body">
<?php


			while ($row = mysql_fetch_array($rows)) {



				$id = $row['this_id'];

				$xiaoquming = $row['xiaoquming'];

				$dizhi = $row['dizhi'];

				$ditie = $row['ditie'];

				$gongjiao = $row['gongjiao'];

				$tupian = $row['tupian'];

				$wuyeleixing = $row['wuyeleixing'];

				$jungongshijian = $row['jugongshijian'];

				$kaifashang = $row['kaifashang'];

				$wuyegongsi = $row['wuyegongsi'];

				$wuyefei = $row['wuyefei'];

				$gaikuang = $row['gaikuang'];

				$tingchewei = $row['tingchewei'];

				$lvhualv = $row['lvhualv'];

				$rongjilv = $row['rongjilv'];

				$zongjianzhumianji = $row['zongjianzhumianji'];


				$tupian = $row->tupian;
				$time = $row->time;
   				 $tupian = explode(";",$tupian);

				$jiage = $row['jiage'];


				$jiage = $db->GetSingleValOrDefault("select sum(jiage)/sum(mianji) as jiage from zufang where type=1 and xiaoqu=$id",0);
				if($jiage==""){
						 $jiage =0;
					}
					else{
						$jiage = number_format($jiage,2);
					}


				$db->Execute("update xiaoqu set jiage=$jiage where this_id=$id");

				$zufang = $db->GetCount("select * from zufang where xiaoqu=$id and type=0");

				$ershoufang = $db->GetCount("select * from zufang where xiaoqu=$id and type=1");



?>
    <li id="li_apf_id_12" class="">
	<div class="property2" id="apf_id_12">
	    <div class="photo">
	        <a href="xiaoqu_detail.php?id=<?php echo $id?>" class="photo" title="<?php echo $xiaoquming?>" alt="<?php echo $xiaoquming ?>" target="_blank"><img class="thumbnail" id="apf_id_13_a" src="<?php echo './'.$tupian[0]?>"   onerror="this.src='./images/avatar.gif'" alt="<?php echo $xiaoquming?>" width="150" height="113"></a>
	    </div>
	    <div class="details">
	    	<h4>
				<a id="comm_name_qt_apf_id_12" href="xiaoqu_detail.php?id=<?php echo $id?>" target="_blank" ><?php echo $xiaoquming ?></a>&nbsp;
	        </h4>
	        <address id="comm_addr_qt_apf_id_12">
            	<span style="overflow:hidden;float:left; font-family:Simsun"><?php echo $dizhi?></span>
				<!--<a class="lookmap" target="_blank" href="#" rel="nofollow">地图</a>-->
            </address>

                        <p class="date">
            	竣工日期：<?php echo $jungongshijian?>            </p>
            	        <p class="house">
	                        <span id="comm_sale_qt_apf_id_12">二手房
	                		                <a href="#" target="_blank" style="color: #335293;">(<?php echo $ershoufang?>)</a>
		                            </span>
            	                        <span id="comm_rent_qt_apf_id_12">租房
                			                <a href="#" target="_blank" style="color: #335293;">(<?php echo $zufang ?>)</a>
		                            </span>
            	        </p>

	        <p class="commseries">
	                        <a href="xiaoqu_detail.php?id=<?php echo $id?>" class="icons01" target="_blank" _soj="communitylist">小区详情</a>
            	        </p>
		</div>
		<div class="price">
		   	<span>
				<?php
					if($db->isFavorites(3,$id)){
				?>
					<a href="shoucang.php?action=cancle&sc_type=3&dx_id=<?php echo $id;?>" id="cz_favorite">
						<img id="shoucang" style="cursor:pointer" title="取消收藏"
							onmouseover="javascript:this.src='images/star_none.ico';"
							onmouseout="javascript:this.src='images/fav.ico';"
							width="20" src="images/fav.ico">
					</a>
				<?php
					}else{
				?>
					<a href="shoucang.php?sc_type=3&dx_id=<?php echo $id;?>" title="收藏信息" id="cz_favorite">
						<img id="shoucang" style="cursor:pointer" title="收藏"
							onmouseover="javascript:this.src='images/fav.ico';"
							onmouseout="javascript:this.src='images/star_none.ico';"
							width="20" src="images/star_none.ico">
					</a>
				<?php
					}
				?>
			</span><br/>
			<span id="comm_price_qt_apf_id_12"><strong><?php echo $jiage?></strong></span>&nbsp;万元/平米
		    <br>
		    <!--<span id="comm_chg_qt_apf_id_12" class="down" style="align:left">↓0.22%</span>-->
		</div>
	   </div>

    </li>
    <?php }



    ?>
    </ol>
                <div class="multi_page_div">
                <div class="multipage" style="float:right;">
                	<?php
		if($page!=1){
			echo '<a class="prv" href="'.deleteRepeatVar($current_url,'page').'&page='.($page-1).'"><span>上一页</span></a>';
		}
		if($max_page>10){
			$ind = $page-5;
		}
		if($ind<=0){
			$ind=1;
		}
		$page_show_total = 10;//最多显示10页
		for(;$ind<=$max_page;$ind++){
			if($ind==$page){
				echo '<strong><span>'.$ind.'</span></strong>';
			}else{
				echo '<a href="'.deleteRepeatVar($current_url,'page').'&page='.$ind.'"><span>'.$ind.'</span></a>';
			}
			$page_show_total--;
			if($page_show_total==0){
				break;
			}
		}
		if($page!=$max_page && $max_page!=0){
			echo '<a class="next" href="'.deleteRepeatVar($current_url,'page').'&page='.($page+1).'"><span>下一页</span></a>';
		}

		if($total_item==0){
				echo "没有找到符合的信息！";
		}

		$db->Close();
	?>

        </div>                </div>

                <div style="clear:both;"></div>
              <!--  <div class="divBrokerList">
					找个满意的经纪人，事半功倍！ <a href="#" target="_blank">现在去找</a>
				</div>-->
                    </div>
	</div>

</div>
